let path = "http://localhost:8080/Saxon_Blog_war/";
let account = document.getElementById("userAccount");
account={"status":"false"}
let newpassword = document.getElementById("newpassword");
newpassword={"status":"false"}
let rnewpassword = document.getElementById("rnewpassword");
rnewpassword={"status":"false"}
//修改密码，对帐户的检查
function account_check() {
    $.get({
        url:path+"/pwdmodify/account",
        data:{"userAccount":$("#userAccount").val()},
        success:function (data){
            if (data=="true"){
                $("#userAccount").addClass("is-valid");
                $("#userAccount").removeClass("is-invalid");
                $("#userAccount_span").attr("hidden","true")
                account.status="true";
            }else{
                $("#userAccount").addClass("is-invalid");
                $("#userAccount").removeClass("is-valid");
                $("#userAccount_span").removeAttr("hidden")
                $("#userAccount_span").html("你的账户不存在")
                account.status="false";
            }
        }
    })
}
//对新密码的验证
function newpassword_check() {
    $.get({
        url:path+"/pwdmodify/newpassword",
        data:{"newpassword":$("#newpassword").val()},
        success:function (data){
            if (data=="true"){
                $("#newpassword").addClass("is-valid");
                $("#newpassword").removeClass("is-invalid");
                $("#newpassword_span").attr("hidden","true")
                newpassword.status="true";
            }else{
                $("#newpassword").addClass("is-invalid");
                $("#newpassword").removeClass("is-valid");
                $("#newpassword_span").removeAttr("hidden")
                $("#newpassword_span").html("你的密码必须要在6-20位之间")
                newpassword.status="false";
            }
        }
    })
}
//再次确认密码
function rnewpassword_check() {
    $.get({
        url:path+"/pwdmodify/rnewpassword",
        data:{"rnewpassword":$("#rnewpassword").val(),"newpassword":$("#newpassword").val()},
        success:function (data){
            if (data=="true"){
                $("#rnewpassword").addClass("is-valid");
                $("#rnewpassword").removeClass("is-invalid");
                $("#rnewpassword_span").attr("hidden","true")
                rnewpassword.status="true";
            }else{
                $("#rnewpassword").addClass("is-invalid");
                $("#rnewpassword").removeClass("is-valid");
                $("#rnewpassword_span").removeAttr("hidden")
                $("#rnewpassword_span").html("你的两次密码不一致")
                rnewpassword.status="false";
            }
        }
    })
}
//提交修改
function submit_change() {
    console.log(account.status)
    console.log(rnewpassword.status)
    console.log(newpassword.status)
    if (account.status=="true"&&newpassword.status=="true"&&rnewpassword.status=="true"){
        if (confirm("确认修改密码?")){
            return true;
        }else {
            return false;
        }
    }
    else {
        confirm("亲，如果不改密码的话，就只有慢慢想了哟")
        return false;
    }
}